<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<table>
    <tr>
        <td>用戶</td>
        <td >用戶角色</td>
        <td>密码</td>

        <td>年龄</td>
        <td>性别</td>
        <td>状态</td>
        <td>是否锁定</td>
    </tr>
    <tr th:each="user :${userAll}">
        <td th:text="${user.username}">用戶</td>
        <td th:text="${user.roleName}">用戶</td>
        <td th:text="${user.password}">密码</td>
        <td th:text="${user.age}">年龄</td>
        <td th:text="${user.sex == 0 ? '男' : '女'}">性别</td>
        <td th:text="${user.enable==0 ? '禁用':'启用'}" id="status">状态</td>
        <td th:text="${user.locked==0?'未锁定':'锁定'}">是否锁定</td>
        <td>
            <button type="button"  th:onclick="|del(${user.uid},${user.enabled})|">删除</button>
        </td>
    </tr>
</table>
</body>
<script src="webjars/jquery/3.5.1/jquery.js"></script>
<script>
    function del(uid,enabled) {
        if(enabled==0){
        $.ajax({
            url:"/dba/del",
            dataType:"JSON",
            data:{uid:uid},
            success:function (msg) {
                if(msg.code==200){
                    alert('删除成功');
                    window.location.reload();
                }
            }
        })
        }else{
            alert("启用状态")
        }

    }
</script>
</html>